package org.activequant.core.domainmodel.marketscanner;

import static org.activequant.util.tools.IdentityUtils.equalsTo;
import static org.activequant.util.tools.IdentityUtils.safeCompare;
import static org.activequant.util.tools.IdentityUtils.safeHashCode;

import java.io.Serializable;

import org.activequant.core.domainmodel.InstrumentSpecification;
import org.activequant.core.types.TimeStamp;
/**
 * InstrumentSpecificationDetails implements Comparable&lt;InstrumentSpecificationDetails&gt;, Serializable<br/>
 * Holds the following associated variables:
 * <ul>
 * <li>instrumentSpecification(InstrumentSpecification)</li>
 * <li>marketName(String)</li>
 * <li>tradingClass(String)</li>
 * <li>minTick(String)</li>
 * <li>priceMagnifier(int)</li>
 * <li>orderTypes(String)</li>
 * <li>validExchanges(String)</li>
 * <li>longName(String)</li>
 * <li>cusip(String)</li>
 * <li>ratings(String)</li>
 * <li>descAppend(String)</li>
 * <li>bondType(String)</li>
 * <li>couponType(String)</li>
 * <li>callable(boolean)</li>
 * <li>putable(boolean)</li>
 * <li>coupon(double)</li>
 * <li>convertible(boolean)</li>
 * <li>maturity(String)</li>
 * <li>issueDate(String)</li>
 * <li>nextOptionDate(String)</li>
 * <li>nextOptionType(String)</li>
 * <li>nextOptionPartial(boolean)</li>
 * <li>notes(String)</li>
 * <li>timeStamp(TimeStamp)</li>
 * </ul>
 * @author Dimitar
 *
 */
public class InstrumentSpecificationDetails implements Comparable<InstrumentSpecificationDetails>, Serializable{
	private static final long serialVersionUID = -3263322976345588675L;
	public static final int NOT_SET = -1;
	private Long id = null;
	//natural key:
	private InstrumentSpecification instrumentSpecification;
	private String 	marketName;
	private String 	tradingClass;
	
	private double 	minTick=NOT_SET;
	private int     priceMagnifier=NOT_SET;
	private String 	orderTypes;
	private String 	validExchanges;
	private String 	longName;

    // BOND values
	private String 	cusip;
	private String 	ratings;
	private String 	descAppend;
	private String 	bondType;
	private String 	couponType;
	private boolean callable = false;
	private boolean putable = false;
	private double 	coupon = 0;
	private boolean convertible = false;
	private String 	maturity;
	private String 	issueDate;
	private String 	nextOptionDate;
	private String 	nextOptionType;
	private boolean nextOptionPartial = false;
	private String 	notes;
	
	private String  contractMonth;
	private String  industry;
	private String  category;
	private String  subcategory;
	private String  timeZoneId;
	private String  tradingHours;
	private String  liquidHours;

	
	private TimeStamp timeStamp;

	public InstrumentSpecificationDetails(){
		
	}
		
	/**
	 * {@inheritDoc}
	 */
	public int hashCode() {
		// ATTENTION: keep in sync with compareTo()
		return safeHashCode(this.instrumentSpecification) 
			+ safeHashCode(this.tradingClass)
			+ safeHashCode(this.marketName)
			+ safeHashCode(this.minTick)
			+ safeHashCode(this.priceMagnifier);
	}
 	
	/**
	 * {@inheritDoc}
	 */
	public int compareTo(InstrumentSpecificationDetails other) {
		// ATTENTION: keep in sync with hashCode();
		int rc;
		
		rc = safeCompare(this.instrumentSpecification, other.instrumentSpecification);
		if(rc != 0) return rc;
		rc = safeCompare(this.tradingClass, other.tradingClass);
		if(rc != 0) return rc;
		rc = safeCompare(this.marketName, other.marketName);
		if(rc != 0) return rc;		
		rc = safeCompare(this.minTick, other.minTick);
		if(rc != 0) return rc;		
		rc = safeCompare(this.priceMagnifier, other.priceMagnifier);
		if(rc != 0) return rc;		
		return rc;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(Object other) {
		// NOTE: delegates to compareTo()
		return equalsTo(this, other);
	}
	
    @Override
    public String toString() {
		String ret= instrumentSpecification==null?"":(instrumentSpecification+"\t");
		ret += tradingClass==null?"":(tradingClass+ "\t"); 
		ret += marketName==null?"":(marketName+ "\t"); 
		ret += minTick==NOT_SET?"":(minTick+ "\t");
		ret += priceMagnifier==NOT_SET?"":(priceMagnifier);
		return ret;
	}

	public InstrumentSpecification getInstrumentSpecification() {
		return instrumentSpecification;
	}

	public void setInstrumentSpecification(InstrumentSpecification instrumentSpecification) {
		this.instrumentSpecification = instrumentSpecification;
	}

	public String getMarketName() {
		return marketName;
	}

	public void setMarketName(String marketName) {
		this.marketName = marketName;
	}

	public String getTradingClass() {
		return tradingClass;
	}

	public void setTradingClass(String tradingClass) {
		this.tradingClass = tradingClass;
	}

	public double getMinTick() {
		return minTick;
	}

	public void setMinTick(double minTick) {
		this.minTick = minTick;
	}

	public int getPriceMagnifier() {
		return priceMagnifier;
	}

	public void setPriceMagnifier(int priceMagnifier) {
		this.priceMagnifier = priceMagnifier;
	}

	public String getOrderTypes() {
		return orderTypes;
	}

	public void setOrderTypes(String orderTypes) {
		this.orderTypes = orderTypes;
	}

	public String getValidExchanges() {
		return validExchanges;
	}

	public void setValidExchanges(String validExchanges) {
		this.validExchanges = validExchanges;
	}

	public String getLongName() {
		return longName;
	}

	public void setLongName(String longName) {
		this.longName = longName;
	}

	public String getCusip() {
		return cusip;
	}

	public void setCusip(String cusip) {
		this.cusip = cusip;
	}

	public String getRatings() {
		return ratings;
	}

	public void setRatings(String ratings) {
		this.ratings = ratings;
	}

	public String getDescAppend() {
		return descAppend;
	}

	public void setDescAppend(String descAppend) {
		this.descAppend = descAppend;
	}

	public String getBondType() {
		return bondType;
	}

	public void setBondType(String bondType) {
		this.bondType = bondType;
	}

	public String getCouponType() {
		return couponType;
	}

	public void setCouponType(String couponType) {
		this.couponType = couponType;
	}

	public boolean isCallable() {
		return callable;
	}

	public void setCallable(boolean callable) {
		this.callable = callable;
	}

	public boolean isPutable() {
		return putable;
	}

	public void setPutable(boolean putable) {
		this.putable = putable;
	}

	public double getCoupon() {
		return coupon;
	}

	public void setCoupon(double coupon) {
		this.coupon = coupon;
	}

	public boolean isConvertible() {
		return convertible;
	}

	public void setConvertible(boolean convertible) {
		this.convertible = convertible;
	}

	public String getMaturity() {
		return maturity;
	}

	public void setMaturity(String maturity) {
		this.maturity = maturity;
	}

	public String getIssueDate() {
		return issueDate;
	}

	public void setIssueDate(String issueDate) {
		this.issueDate = issueDate;
	}

	public String getNextOptionDate() {
		return nextOptionDate;
	}

	public void setNextOptionDate(String nextOptionDate) {
		this.nextOptionDate = nextOptionDate;
	}

	public String getNextOptionType() {
		return nextOptionType;
	}

	public void setNextOptionType(String nextOptionType) {
		this.nextOptionType = nextOptionType;
	}

	public boolean isNextOptionPartial() {
		return nextOptionPartial;
	}

	public void setNextOptionPartial(boolean nextOptionPartial) {
		this.nextOptionPartial = nextOptionPartial;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}
	
	
	
	public String getContractMonth() {
		return contractMonth;
	}

	public void setContractMonth(String contractMonth) {
		this.contractMonth = contractMonth;
	}

	public String getIndustry() {
		return industry;
	}

	public void setIndustry(String industry) {
		this.industry = industry;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}
	
	public String getSubcategory() {
		return subcategory;
	}

	public void setSubcategory(String subcategory) {
		this.subcategory = subcategory;
	}

	public String getTimeZoneId() {
		return timeZoneId;
	}

	public void setTimeZoneId(String timeZoneId) {
		this.timeZoneId = timeZoneId;
	}

	public String getTradingHours() {
		return tradingHours;
	}

	public void setTradingHours(String tradingHours) {
		this.tradingHours = tradingHours;
	}

	public String getLiquidHours() {
		return liquidHours;
	}

	public void setLiquidHours(String liquidHours) {
		this.liquidHours = liquidHours;
	}

	public TimeStamp getTimeStamp() {
		return timeStamp;
	}

	public void setTimeStamp(TimeStamp timeStamp) {
		this.timeStamp = timeStamp;
	}

	/**
	 * returns the associated id(Long)
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * sets the associated id(Long) with the given id(Long)
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	
	/**
	 * returns whether the associated id(Long) is not <code>null</code><br/>
	 * assigned id?
	 * @return
	 */
	public boolean hasId() {
		return id != null;
	}
	
}
